package com.google.code.bankagregator.adapter.bank.forum.parser.deposit;

import com.google.code.bankagregator.adapter.bank.forum.parser.FuncForDepParser;
import com.google.code.bankagregator.adapter.exception.AdapterConnectException;
import com.google.code.bankagregator.entities.Currency;
import com.google.code.bankagregator.entities.Deposit;
import com.google.code.bankagregator.entities.State;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: kirill
 * Date: 15.06.13
 * Time: 18:45
 * To change this template use File | Settings | File Templates.
 */
public class ForumDepFreeParser {
    private static final String DEPOSIT_URL = "http://www.forum.ua/forumua/ua/mainnavigation/retail_1/deposits_3/" +
            "depositprogramvilnyyruh/depositprogramvilnyyruh.jsp";
    private static final int INDEX_TR_WITH_UAH_RATE = 0;
    private static final int INDEX_TR_WITH_USD_RATE = 1;
    private static final int INDEX_TR_WITH_EUR_RATE = 2;
    private static final int INDEX_TR_WITH_UAH_MIN_AMOUNT = 3;
    private static final int INDEX_TR_WITH_USD_MIN_AMOUNT = 5;
    private static final int INDEX_TR_WITH_EUR_MIN_AMOUNT = 8;
    private static final int INDEX_LI_WITH_REFILL = 3;
    private static final int INDEX_WITH_REFILL = 3;


    /**
     * Get UAH deposit
     *
     * @return deposit params
     * @throws AdapterConnectException
     */
    public List<Deposit> getUAHDeposit() throws AdapterConnectException {
        List<Deposit> depositParam = new FuncForDepParser(DEPOSIT_URL).parser(INDEX_TR_WITH_UAH_RATE, INDEX_TR_WITH_UAH_MIN_AMOUNT,
                Currency.UAH, State.ACTIVE, DEPOSIT_URL, INDEX_LI_WITH_REFILL, INDEX_WITH_REFILL);
        return depositParam;
    }

    /**
     * Get USD deposit
     *
     * @return deposit params
     * @throws AdapterConnectException
     */
    public List<Deposit> getUSDDeposit() throws AdapterConnectException {
        List<Deposit> depositParam = new FuncForDepParser(DEPOSIT_URL).parser(INDEX_TR_WITH_USD_RATE, INDEX_TR_WITH_USD_MIN_AMOUNT,
                Currency.USD, State.ACTIVE, DEPOSIT_URL, INDEX_LI_WITH_REFILL, INDEX_WITH_REFILL);
        return depositParam;
    }

    /**
     * Get EUR deposit
     *
     * @return deposit params
     * @throws AdapterConnectException
     */
    public List<Deposit> getEURDeposit() throws AdapterConnectException {
        List<Deposit> depositParam = new FuncForDepParser(DEPOSIT_URL).parser(INDEX_TR_WITH_EUR_RATE, INDEX_TR_WITH_EUR_MIN_AMOUNT,
                Currency.EUR, State.ACTIVE, DEPOSIT_URL, INDEX_LI_WITH_REFILL, INDEX_WITH_REFILL);
        return depositParam;
    }
}

